<template>
	<view class="agentShare">
		<!-- <view class="cu-bar bg-white">
			<view class="action">
				<text class="cuIcon-back text-gray"></text>
				返回
			</view>
			<view class="content text-bold">操作条</view>
		</view> -->
		<!-- <web-view :webview-styles="webviewStyles" src="http://192.168.110.45:3000/" @message="onWebViewPost"></web-view> -->
	</view>
</template>

<script>
// import Painter from '../../wxcomponents/painter/painter.js';
export default {
	// components: {
	// 	Painter
	// },
	onLoad(obj) {
		console.log(obj);
		if (obj.id) {
		}
	},
	data() {
		return {
			paintPallette: {},
			modalVisible: false,
			tempFilePath: null,
			webviewStyles:{
				top:'100rpx'
			}
		};
	},
	onShareAppMessage(obj) {
		return {
			title: '自定义转发标题',
			path: '/agentPages/agent/agentShare'
		};
	},
	methods: {
		openModal() {
			this.modalVisible = true;
			let self = this;
			this.paintPallette = {
				width: '640rpx',
				height: '800rpx',
				background: '#ffffff',
				views: [
					{
						type: 'qrcode',
						content: 'abc',
						css: {
							width: '600rpx',
							height: '600rpx',
							top: '24rpx'
						},
						id: 'code'
					},
					{
						type: 'text',
						text: 'abc',
						css: {
							width: '640rpx',
							fontSize: '30rpx',
							textAlign: 'center',
							top: ['24rpx', 'code']
						}
					}
				]
			};
		},
		canvasOk(e) {
			console.log('img', e);
		},
		saveImg() {
			let self = this;
			wx.canvasToTempFilePath(
				{
					canvasId: 'k-canvas',
					success: res => {
						console.log(res.tempFilePath);
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function(res) {
								console.log(res);
								uni.showToast({
									title: '保存成功'
								});
							}
						});
					},
					fail: err => {
						console.log(err);
					}
				},
				this.$refs.painter
			);
		},
		onWebViewPost(res){
			console.log(res)
		}
	}
};
</script>

<style lang="less">
.agentShare {
	.btnContainer {
		margin: 100rpx auto;
		text-align: center;
	}
	.modalBtnContainer {
		margin: 12rpx 0;
		text-align: center;
	}
}
</style>
